package May15ch17ex1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer {
	public static void main(String[] args) throws IOException {

		ServerSocket ss = null;
		int portNumber = 1234;
		ss = new ServerSocket(portNumber);
		while (true) {
			Socket socket = ss.accept();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
			String message = reader.readLine();
			System.out.println(message);
			if (message.contains("done")) {
				socket.close();
				ss.close();
				break;
			}
		}
	}
}
